package com.yimi.yinhepda.views.main.my_module;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.pda.uce.commom.util.LoginUserModule;
import com.uce.pda.activity.ArriveActivity;
import com.yimi.yinhepda.base.BaseFragment;
import com.yimi.yinhepda.R;
import com.pda.ym.callbacks.UICallBack;
import com.yimi.yinhepda.entity.response.QueryUCExpressResponse;
import com.pda.ym.net.NetRequest;
import com.pda.ym.utils.ActivityStack;
import com.yimi.yinhepda.utils.Common;
import com.pda.ym.utils.Constants;
import com.yimi.yinhepda.utils.ToastUtil;
import com.yimi.yinhepda.views.login.activity.LoginActivity;
import com.yimi.yinhepda.views.offline.OffLineOperatorListActivity;

import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * @author: lj
 * Date: 2019/9/19 15:52
 * Description:首页
 */
public class MyFragment extends BaseFragment {

    @Bind(R.id.tv_user_name)
    TextView tvUserName;
    @Bind(R.id.tv_dept_name)
    TextView tvDeptName;
    @Bind(R.id.imag_company_icon)
    ImageView imagCompanyIcon;

    @Override
    public String getPageName() {
        return "我的";
    }

    @Override
    public int getContentViewId() {
        return R.layout.fragmen_my;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        tvUserName.setText(String.format("%s", sharedPreferUtil.getEmpName() + " " + sharedPreferUtil.getWorkNum()));
        tvDeptName.setText(sharedPreferUtil.getValue(Common.DEPT_NAME));
        imagCompanyIcon.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                Intent intent = new Intent(getActivity(),PowerActivity.class);
                startActivity(intent);
                return false;
            }
        });

    }

    @OnClick({R.id.ll_my_qty, R.id.ll_local_set, R.id.ll_download_data, R.id.ll_offline_option, R.id.ll_quite})
    @Override
    protected void onClickBtn(View v) {
        super.onClickBtn(v);
        switch (v.getId()) {
            case R.id.ll_my_qty:
                //我的货量
                ToastUtil.showToast("敬请期待");
                break;
            case R.id.ll_local_set:
                //本机设置
                toActivity(LocalSettingActivity.class);
                break;
            case R.id.ll_download_data:
                //数据下载
                toActivity(BaseDataActivity.class);
                break;
            case R.id.ll_offline_option:
                //离线操作
                toActivity(OffLineOperatorListActivity.class);
                break;
            case R.id.ll_quite:
                //退出登录
                Common.uploadPdaManagerLogInfo(getContext(), 2);
                LoginUserModule.getInstance().deleteUserInfo();
                ActivityStack.getInstance().exit();
                Intent loginIntent = new Intent(getContext(), LoginActivity.class);
                loginIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(loginIntent);
                break;
            default:
                break;
        }
    }

}
